<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<link rel="stylesheet" href="${initParam.root}/css/board.css" type="text/css">
<meta charset="UTF-8">
<script type="text/javascript">
   $(document).ready(function() {
         $("#deleteDeal").click(   function() {
            if(confirm("삭제하시겠습니까?")==true){
         location.href = "${initParam.root}admin/deleteDeal.do?dealNumber=${requestScope.map.dealVo.dealNumber}";
         }
      });
      $("#tabs").tabs();
      
		$("#delImg").click(function(){
			if(confirm("해당글을 삭제하시겠습니까?")==false){
				return;
			}
		});
		
});//ready
</script>
<form id="show" action="${initParam.root}customer/addCart.do">
   <table class="registerMemberTable"  style="margin: 0 auto ; width: 600px"  >
      <tr>
         <td colspan="3" align="center">
            <h2>상품상세보기</h2> <input type="hidden" name="dealNumber"   value="${requestScope.map.dealVo.dealNumber}">
         </td>
      </tr>
      <tr>
         <td rowspan="8"><img   src="${initParam.root }upload/${requestScope.map.dealVo.dealImage }"
            width="300px" height="300px"></td>
      </tr>
      <tr>
         <td >상품명</td>
         <td><input type="text" name="dealTitle"
            value="${requestScope.map.dealVo.dealTitle}" readonly="readonly">
         </td>
      </tr>
      <tr>
         <td>카테고리</td>
         <td><input type="text" name="category"
            value="${requestScope.map.dealVo.category}" readonly="readonly">
         </td>
      </tr>
      <tr>
         <td>등록자</td>
         <td><input type="text" name="sellerId"
            value="${requestScope.map.dealVo.sellerId}" readonly="readonly">
         </td>
      </tr>
      <tr>
         <td>상품가격</td>
         <td><input type="text" name="dealPrice"
            value="${requestScope.map.dealVo.dealPrice}" readonly="readonly">
         </td>
      </tr>
      <c:choose>
      <c:when test="${requestScope.map.dealVo.dealCount!=0}">
      <tr>
         <td>남은수량</td>
         <td><input type="text" name="dealCount"
            value="${requestScope.map.dealVo.dealCount}" readonly="readonly">
         </td>
      </tr>
      <tr>
         <td>구입수량</td>
         <td><input type="number" name="cartCount" min="1" max="${requestScope.map.dealVo.dealCount }"
            value="0"></td>
      
      </tr>
      </c:when>
      <c:otherwise>
      <tr>
      <td rowspan="2" colspan="2">
      <img   src="${initParam.root }upload/soldout2.jpg" height="80px" width="200px"><br>
      </td>
      </tr>
      <tr><td></td></tr>
      </c:otherwise>
      </c:choose>
      <tr>
         <td>마감일</td>
         <td><input type="text" name="dealEndDate"
            value="${requestScope.map.dealVo.dealEndDate}" readonly="readonly">
         </td>
      </tr>
      <tr>
         <td colspan="3" align="right"><c:choose>
               <c:when test="${sessionScope.login.authNumber==1 && requestScope.map.dealVo.dealCount!=0}">
                  <input type="hidden" name="customerId"   value="${sessionScope.login.customerId }">
                  <input type="submit" value="장바구니담기">
               </c:when>
               <c:when test="${sessionScope.login.authNumber==11 && requestScope.map.dealVo.sellerId==sessionScope.login.sellerId}"><a
               href="${initParam.root}seller/update_Deal.do?dealNumber=${requestScope.map.dealVo.dealNumber}">
               <img   id="writeImg" src="${initParam.root }/img/modify_btn.jpg"></a>
               </c:when>
               <c:when test="${sessionScope.login.authNumber==100 }">
                  <input type="button" id="deleteDeal" value="상품삭제">
               </c:when>
            </c:choose></td>
      </tr>
   </table>
</form>


<hr>



<body>
   <table class="list">
      <caption>Q&A</caption>
      <thead>
      <tr>
         <th class="title">제목</th>
         <th class="name">이름</th>
         <th class="date">작성일</th>
         <th class="hit">HIT</th>
         </tr>      
      </thead>   
      
         <c:forEach var="bvo" items="${requestScope.map.lvo.list}">      
         <tr>
            <td align=left>               
               <a href="${initParam.root}common/showContent.do?dealNumber=${requestScope.map.dealVo.dealNumber}&no=${bvo.no }">
               <c:if test="${bvo.relevel!=0}">
                  <c:forEach begin="0" end="${bvo.relevel}" step="1">&nbsp;&nbsp;</c:forEach>
                  <img src="${initParam.root }/img/reply.jpg">
               </c:if>${bvo.title}</a>
            </td>
            <td>${bvo.writer }</td>
            <td>${bvo.writeDate }</td>
            <td>${bvo.viewCount }</td>
         </tr>      
         </c:forEach>
   </table><br></br>   
   
<!-- 구매자만 글쓰기 가능  -->
<div align="center">
<c:choose>
   <c:when test="${sessionScope.login.authNumber==1 }">
      <a href="${initParam.root }common/qnaWriteView.do?dealNumber=${requestScope.map.dealVo.dealNumber}"><img id="writeImg" src="${initParam.root }/img/write_btn.jpg" border="0"></a>
      <br></br>   
   </c:when>
</c:choose>
</div>
   
   <!-- 페이징 처리 -->      
   <br></br>    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   <!-- 페이징 처리 -->   
    <p class="paging">
    <c:if test="${requestScope.map.lvo.pagingBean.previousPageGroup}">
    <a href=
    "${initParam.root}common/showDealContents.do?pageNo=${requestScope.map.lvo.pagingBean.
    startPageOfPageGroup-1}&dealNumber=${requestScope.map.dealVo.dealNumber}">◀&nbsp;</a>
    </c:if>
    &nbsp;&nbsp;   
   <c:forEach var="i" 
   begin="${requestScope.map.lvo.pagingBean.startPageOfPageGroup}"
    end="${requestScope.map.lvo.pagingBean.endPageOfPageGroup}">
    <c:choose>
    <c:when test="${requestScope.map.lvo.pagingBean.nowPage!=i}">
    <a href="${initParam.root}common/showDealContents.do?pageNo=${i}&dealNumber=${requestScope.map.dealVo.dealNumber}">${i}</a>
    </c:when>
    <c:otherwise>
   ${i}
   </c:otherwise>
   </c:choose>
   </c:forEach>    
   &nbsp;&nbsp;
    <c:if test="${requestScope.map.lvo.pagingBean.nextPageGroup}">
    <a href="${initParam.root}common/showDealContents.do?pageNo=${requestScope.map.lvo.pagingBean.
    endPageOfPageGroup+1}&dealNumber=${requestScope.map.dealVo.dealNumber}">
    ▶
    </a>
    </c:if>   
    </p>    
</body>